package com.learn.xueer.ui.activity

import android.content.Intent
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_welcome.*
import me.hgj.jetpackmvvm.base.viewmodel.BaseViewModel
import com.learn.xueer.app.base.BaseActivity
import com.learn.xueer.app.util.CacheUtil
import com.learn.xueer.app.util.SettingUtil
import com.learn.xueer.databinding.ActivityWelcomeBinding
import me.hgj.jetpackmvvm.util.IS_EYE_CARE_OPEN

/**
 * 作者　: hegaojian
 * 时间　: 2020/2/22
 * 描述　:
 */
class WelcomeActivity : BaseActivity<BaseViewModel, ActivityWelcomeBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        //防止出现按Home键回到桌面时，再次点击重新进入该界面bug
        if (intent.flags and Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT !== 0) {
            finish()
            return
        }
        IS_EYE_CARE_OPEN = CacheUtil.isCareRye()
        if (IS_EYE_CARE_OPEN) {
            openEye()
        } else {
            closeEye()
        }
        welcome_baseview.setBackgroundColor(SettingUtil.getColor(this))
        if (CacheUtil.isLogin()) {
            startActivity(Intent(this, MainActivity::class.java))
        } else {
            startActivity(Intent(this, LoginActivity::class.java))
        }
        finish()
    }

}